import {Component} from '@angular/core';
import {
  Events,
  AlertController,
  App,
  ModalController,
  NavController,
  NavParams,
  ActionSheetController,
  PopoverController
} from 'ionic-angular';
import {DomSanitizer} from '@angular/platform-browser';
import {TaskDetailService} from './detail.service';
import {Config} from '../../../providers/config';
import {Storage} from '@ionic/storage';
import _ from 'lodash';
import {EmpPage} from './emp.component';
import {BT0107Page} from './bt0107.component';
import {ContactChoosePage} from '../../contact/choose/choose.component';
import {FlowApprovalPage} from './flowApproval.component';
import {FlowLogPage} from './flowLog.component';
import {FlowParmeter} from '../../draft/detail/flowParmeter.model';
import {Common} from '../../../providers/common';
import {CashPlanPage} from './cashPlanDetail.component';
import {InfoDetailPage} from '../../info/detail/detail.component';
import {ZcmxListPage} from './zcmxList.component';
import {TaskInfoListPage} from "./infoList.component";
import {FlowPressPage} from "./flowPress.component";
import {DraftDetailPage} from "../../draft/detail/detail.component";

@Component({
  selector: 'page-task-detail',
  templateUrl: './detail.html',
  providers: [TaskDetailService]
})
export class TaskDetailPage {
  moa_page_name: any = "page-task-detail";
  moa_page_explain: any = "流程详情";

  _ = _;
  // 当前登录人ID
  loginid;
  // 当前登录人名
  emname;
  // 文件bid
  id = "";
  // 文件信息带字段
  businessObjectDesList;
  backupBusinessObjectDesList;
  backupFlowParmeter;

  flowControl;

  // 文件信息
  businessObjectI: any = {};
  // 流程信息
  workFlowParmeter: any = {};
  //
  flowParmeter: FlowParmeter;

  // 选择的下一节点类型
  nextNodeType;
  // 选择的下一节点编号
  nextNodeNum;
  // 节点名称
  //nodeName;
  //参与人
  empnames = [];
  empnamesId = [];

  // 选择下一节点人是否多选，0 单选 1多选
  isSelAddr = "1";


  // 附件节点
  attachsNodes;
  // 附件
  attachs;

  // 缓存通过组织树选择的人员
  // 结构如下：
  // [{
  //   empid:"A938493525",
  //   name:"冯镜蒯",
  //   orgid:"xtyfz",
  //   loginid:"fengjk",
  //   titleid:"ybyg"
  // },{}]
  defaultEmpByTree = [];

  // 待办 1, 未办 2,已办 3, 未阅 4, 已阅 5
  wkiType = "";

  // 1 未办 8 未阅
  wkiState = "";

  // 标题
  titles = {
    "1": "待办文件",
    "2": "未办文件",
    "3": "已办文件",
    "4": "未阅文件",
    "5": "已阅文件",
    "6": "流程中心文件"
  }

  // 当前登录人所在的部门、组织
  allOrgmembers = [];
  // 转办选择的部门orgid
  orgidWhileSwtich;

  viewListButton = null;
  showRelatedMetters = null;

  markedWords = [];

  pushStatusField = null;

  isInited = null;

  sonFlowTitle: string;

  isGetNextEditorInTime = false;

  isHKLC = false;

  selectedUsers = [];
  selectedLoginid = [];
  selectedOrgid = [];
  selectedTitleid = [];

  constructor(public alertCtrl: AlertController,
              public app: App,
              public modalCtrl: ModalController,
              public navCtrl: NavController,
              public detailService: TaskDetailService,
              private navParams: NavParams,
              private actionSheetCtrl: ActionSheetController,
              private sanitizer: DomSanitizer,
              public config: Config,
              public storage: Storage,
              public common: Common,
              public events: Events,
              public popoverCtrl: PopoverController) {
    this.id = this.navParams.get('id');
    this.wkiType = this.navParams.get('wkiType');
    this.wkiState = this.navParams.get('wkiState');

    this.loadData();

  }

  /**
   * [loadData 初始化数据]
   */
  loadData() {
    var that = this;

    this.storage.get('userInfo').then(function (userInfo) { // 获得当前登录人ID,名字
      if (userInfo) {
        that.loginid = userInfo.loginid;
        that.emname = userInfo.emname;
      }
      return null;
    }).then(function (data) {
      that.detailService.getAllOrgmembers(that.loginid).subscribe(data => { // 获取当前登录人所在的部门、组织
        if (data) {
          that.allOrgmembers = data;
          that.orgidWhileSwtich = that.allOrgmembers[0].orgid; // 默认选择返回的第一个值
        }
      })
    });

    // 获取未阅详情
    this.detailService.getDetail(this.id).then(function (data) {
      console.log(data);
      if (data && data["businessObjectDesList"] && data["businessObjectI"]) {
        if (data["businessObjectI"]["code"] === "-3") {
          let alert = that.alertCtrl.create({
            title: "系统提示",
            message: "您打开该流程的阅读权限获取失败，请检查PC端的OA流程是否正常显示。",
            buttons: [
              {
                text: "确定",
                role: 'cancel',
                handler: () => {
                  that.navCtrl.pop();
                }
              }
            ]
          });
          alert.present();
        }

        that.attachsNodes = _.filter(data["businessObjectDesList"], {"dataType": "BT06", "type": "BT01"}); // 附件节点
        that.attachs = that.formateAttach(that.attachsNodes); // 格式化附件
        that.businessObjectDesList = _.pullAll(data["businessObjectDesList"], that.attachsNodes); // 去掉附件节点，附件节点单独处理
        that.backupBusinessObjectDesList = data["backupBusinessObjectDesList"];
        that.backupFlowParmeter = data["flowParmeter"];
        that.workFlowParmeter = data["workFlowParmeter"];
        that.businessObjectI = data["businessObjectI"];
        that.flowParmeter = data["flowParmeter"];
        that.flowControl = data["flowControl"];
        console.log(that.businessObjectDesList);

        if (that.businessObjectI.bomid === "zjhb") {
          that.pushStatusField = _.find(that.businessObjectDesList, {"fieldid": "pushstatus"});
          console.log(that.pushStatusField);
          _.remove(that.businessObjectDesList, bod => {
            return bod["fieldid"] == "pushstatus";
          })
        }

        if (that.businessObjectI.bomid === "t_info_Doc" && that.businessObjectI.dirid === "Info2167") {
          let readCountNameIndex = _.findIndex(that.businessObjectDesList, {fieldid: "readContName"});
          if (readCountNameIndex > -1) {
            that.businessObjectDesList[readCountNameIndex].fvalue =
              that.businessObjectDesList[readCountNameIndex].fvalue.split(",").join("<br/>");
            that.businessObjectDesList[readCountNameIndex].fvalue =
              that.sanitizer.bypassSecurityTrustHtml(that.businessObjectDesList[readCountNameIndex].fvalue);
          }

          /**
           * 拼装阅读范围数据
           */
          that.storage.get("contact-user-list").then(userList => {
            console.log("userList>>>>>>>>>", userList);
            that.storage.get("contact-org-list").then(orgList => {
              console.log("orgList>>>>>>", orgList);
              if (that.businessObjectI.readCont) {
                let readContList = that.businessObjectI.readCont.split(",");
                if (readContList && readContList.length > 0) {
                  _.forEach(readContList, cont => {
                    let tempList = cont.split("/");
                    let empid = "";
                    let orgid = "";
                    let titleid = "";
                    _.forEach(tempList, temp => {
                      let type = temp.split("=")[0];
                      let id = temp.split("=")[1];
                      switch (type) {
                        case "CN":
                          empid = id;
                          break;
                        case "OU":
                          orgid = id;
                          break;
                        case "TI":
                          titleid = id;
                          break;
                      }
                    });
                    if (empid) {
                      let tempUser = _.find(userList, user => {
                        if (orgid != "gfqz") {
                          return user["empid"] === empid && user["orgids"].indexOf(orgid) > -1
                            && user["titleids"].indexOf(titleid) > -1;
                        } else {
                          return user["empid"] === empid && user["titleids"].indexOf(titleid) > -1;
                        }
                      });
                      console.log("tempUser>>>>>>>>>>>", tempUser);
                      if (tempUser) {
                        let fullOrg = _.find(that.businessObjectI.readContName.split(","), (tempCont:string) => {
                          return tempCont.indexOf(tempUser["emname"]) > -1;
                        });
                        that.selectedUsers.push({
                          empid: empid,
                          full_orgname: fullOrg ? fullOrg : "",
                          loginid: tempUser["loginid"],
                          name: tempUser["emname"],
                          orgid: orgid,
                          titleid: titleid,
                          type: "user"
                        })

                        that.selectedLoginid.push(tempUser["loginid"]);
                      }
                    } else {
                      if (titleid) {
                        let tempQZ = _.find(orgList, org => {
                          return org["name"].indexOf(orgid + "-" + titleid) > -1;
                        });
                        console.log("tempQZ>>>>>>>>>>", tempQZ);
                        if (tempQZ["list"] && tempQZ["list"].length > 0) {
                          that.selectedUsers.push({
                            full_orgname: tempQZ["list"][0]["full_orgname"],
                            name: tempQZ["list"][0]["titlename"],
                            orgid: orgid,
                            titleid: titleid,
                            type: "title"
                          });
                          that.selectedTitleid.push(titleid);
                        }
                      } else {
                        let tempOrg = _.filter(orgList, org => {
                          return org["name"].indexOf(orgid) > -1;
                        });
                        console.log("tempOrg>>>>>>>>>>", tempOrg);
                        if (tempOrg && tempOrg.length > 0) {
                          let listOne = _.map(tempOrg, "list")[0];
                          if (listOne) {
                            if (listOne["reorgname"]) {
                              that.selectedUsers.push({
                                full_orgname: listOne["reorgname"],
                                name: tempOrg["list"][0]["reorgname"],
                                orgid: orgid,
                                reorgid: "gffunds",
                                type: "dept"
                              });
                              that.selectedOrgid.push(orgid);
                            } else {
                              that.selectedUsers.push({
                                full_orgname: listOne["full_orgname"],
                                name: listOne["titlename"],
                                orgid: orgid,
                                titleid: listOne["titleid"],
                                type: "title"
                              });
                              that.selectedTitleid.push(listOne["titleid"]);
                            }
                          }
                        }
                      }
                    }
                  });
                }
              }
            });
          });
        }

        /*//判断是否为基金经理人
         let isApplyTZXTQX = _.find(that.businessObjectDesList, {
         fieldid: "isApplyTZXTQX"
         });
         if (isApplyTZXTQX && isApplyTZXTQX["fvalue"]){
         isApplyTZXTQX["isShow"] = true;
         } else {
         isApplyTZXTQX["isShow"] = false;
         }*/
        //获取子流程标题
        let sonFlowIndex = _.findIndex(that.businessObjectDesList, {
          fieldid: "tzxtsqSubFlow"
        });
        if (that.businessObjectDesList[sonFlowIndex]) {
          let sonBosid = that.businessObjectDesList[sonFlowIndex]["fvalue"];
          that.detailService.getDetail(sonBosid).then((data: any) => {
            if (data["businessObjectDesList"][0]) that.sonFlowTitle = data["businessObjectDesList"][0]["fvalue"];
          });
        }

        that.initViewListButton(data["businessObjectI"]["bomid"], data["businessObjectI"]["bomname"]);

        that.initRelatedMetters();

        that.initNextEditor();

        that.initEditField();


        if (that.businessObjectI.bomid === "TPJ_GF_TRANSFER") {
          if (that.workFlowParmeter.flowCurrNode === "分管领导审批"
            || that.workFlowParmeter.flowCurrNode === "总经理审批") {
            that.isHKLC = true;
          }

          let nreserved1Index = _.findIndex(that.businessObjectDesList, {fieldid: "nreserved1"});
          that.businessObjectDesList[nreserved1Index].fvalue =
            that.common.formatNumberToAccountancy2(that.businessObjectDesList[nreserved1Index].fvalue, null);
          let bostitleIndex = _.findIndex(that.businessObjectDesList, {fieldid: "bostitle"});
          if (bostitleIndex > -1) {
            let temp = that.businessObjectDesList[bostitleIndex].fvalue.split("|");
            if (temp && temp.length > 0) {
              temp[temp.length - 1] = that.common.formatNumberToAccountancy2(temp[temp.length - 1], null);
              that.businessObjectDesList[bostitleIndex].fvalue = temp.join("|");
            }
          }
        }

        // 初始化下一节点处理人
        if (that.workFlowParmeter.nextActivityDtos) {
          //初始化下一节点，下一节点默认选择人
          let firstNode = _.find(that.workFlowParmeter.nextActivityDtos, {"isDefault": "1"});

          // 如果没有设置默认下一节点，取第一个下一节点
          if (!firstNode) {
            firstNode = that.workFlowParmeter.nextActivityDtos[0];
          }

          if (firstNode && firstNode["numb"]) {
            that.flowParmeter.nextNodesRadio = firstNode["numb"];
            that.nextNodeType = firstNode["nodeType"];
            that.onNextNodeChange(firstNode["numb"]);
          }

        }

        //如果是未阅，则将状态更新为已阅
        if (that.wkiState == "8") {
          that.detailService.workitemAsRead(that.workFlowParmeter["flownumb"]).subscribe(data => {
            if (data["code"] == "0") {
              console.log("##task.detail.loadData 已更新成已阅状态");
              that.events.publish('task-detail:read', that.id); // 广播,让已阅列表刷新
            } else {
              console.log("##task.detail.loadData 已阅状态更新失败");
              //console.log(data);
            }
          })
        }
      }

      that.common.bindLinkersEvent('page-task-detail');
    });
  }

  viewList(item) {
    this.navCtrl.push(TaskInfoListPage, {
      "listParams": item
    });
  }

  ionViewDidEnter() {
    console.log("###############ionViewDidEnter");
    // this.app.setTitle('DemoDetail');
    if (this.businessObjectI["bomid"] === "T_HR_ChuChai" && this.isInited) {
      /*this.businessObjectDesList = this.backupBusinessObjectDesList;
       _.forEach(this.businessObjectDesList, bod => {
       let temp = _.find(this.backupBusinessObjectDesList, {fieldid: bod["fieldid"]});
       if (temp) {
       bod["fvalue"] = temp["fvalue"];
       }
       });*/
      this.businessObjectDesList = this.backupBusinessObjectDesList;
      // this.updateWorkFlow("ccsq", null);
      this.detailService.setProperty(this.businessObjectDesList, this.businessObjectI.bomid);
      this.businessObjectDesList = this.detailService.setIsFundMgrProperty(this.businessObjectDesList);

      console.log("businessObjectDesList", this.businessObjectDesList);
      console.log("businessObjectI", this.businessObjectI);
      console.log("flowParmeter", this.flowParmeter);
      console.log("workFlowParmeter", this.workFlowParmeter);
      this.initEditField();

      /*this.flowParmeter = _.assignIn(this.flowParmeter, this.backupFlowParmeter);
       let appConfirmFieldIndex = _.findIndex(this.businessObjectDesList, {fieldid: "appConfirm"});
       this.businessObjectDesList[appConfirmFieldIndex]["fvalue"] = "";
       this.flowParmeter.nextNodesRadio = "startCmBtn";
       this.onNextNodeChange("startCmBtn");
       _.remove(this.workFlowParmeter["nextActivityDtos"], adto => {
       return adto["numb"] === "67965" || adto["numb"] === "67967";
       });*/
    }
  }

  /**
   * 刷新流程节点信息
   */
  updateWorkFlow(type, appConfirm) {
    let that = this;
    switch (type) {
      case "ccsq":
        _.forEach(this.businessObjectDesList, bod => {
          if (bod["fieldid"] === "appConfirm") {
            bod["fvalue"] = appConfirm;
          }
        });
        let entrys = this.formateBusinessObjectDes(this.businessObjectDesList);
        this.detailService.updateBusinessObjectDes(this.id, entrys).subscribe(doResult => {
          if (doResult["code"] == "0") {
            this.storage.get("userInfo").then(user => {
              this.detailService.getWorkFlowInfo(user, this.id, this.businessObjectI.bomid).subscribe(workFlowInfo => {
                console.log("getWorkFlowInfo", workFlowInfo);
                if (workFlowInfo) { // workFlowParmeter 不为空
                  this.workFlowParmeter = workFlowInfo;
                  _.forEach(_.keys(this.flowParmeter), function (key) {
                    // 在workFlowParmeter中能匹配到值
                    if (that.workFlowParmeter[key]) {
                      // 初始化flowParmeter值
                      that.flowParmeter[key] = that.workFlowParmeter[key];
                    } else {
                      that.flowParmeter[key] = null;
                    }
                  });

                  this.flowParmeter.nextNodeEditor = _.uniq(this.flowParmeter.nextNodeEditor);
                  this.flowParmeter.nextNodeEditorName = _.uniq(this.flowParmeter.nextNodeEditorName);
                  console.log(this.flowParmeter.nextNodeEditorName);

                  // 初始化下一节点处理人
                  if (this.workFlowParmeter.nextActivityDtos) {
                    //初始化下一节点，下一节点默认选择人
                    let firstNode = this.workFlowParmeter.nextActivityDtos[0];
                    if (firstNode && firstNode.numb) {
                      this.flowParmeter.nextNodesRadio = firstNode.numb; // 下一节点ID
                      this.onNextNodeChange(firstNode.numb);
                    }
                  }
                }
              });
            });
          }
        });
        break;
    }
  }

  initEditField() {
    switch (this.businessObjectI.bomid) {
      case "T_HR_ChuChai"://出差申请
        let appConfirmFieldIndex = _.findIndex(this.businessObjectDesList, {fieldid: "appConfirm"});
        this.businessObjectDesList[appConfirmFieldIndex]["isEdit"] = false;
        this.businessObjectDesList[appConfirmFieldIndex]["allowNull"] = false;
        this.businessObjectDesList[appConfirmFieldIndex]["fvalue"] = "";
        this.storage.get("userInfo").then(user => {
          if (this.workFlowParmeter["flowCurrNode"] == "申请人确认" &&
            user.loginid === this.workFlowParmeter["flowCurrEditor"]) {
            this.businessObjectDesList[appConfirmFieldIndex]["showHint"] = true;
            this.businessObjectDesList[appConfirmFieldIndex]["hint"] = "如果您需要修改出差明细，" +
              "请对“申请人确认”选择“否”，并进入出差明细修改界面；如果确认此界面的出差明细无误，" +
              "请选择“是”并结束流程。";
            this.businessObjectDesList[appConfirmFieldIndex]["isEdit"] = true;
            _.remove(this.workFlowParmeter["nextActivityDtos"], adto => {
              return adto["numb"] === "67965" || adto["numb"] === "67967";
            });
            this.flowParmeter.nextNodesRadio = "startCmBtn";
            this.onNextNodeChange("startCmBtn");
          } else {
            this.businessObjectDesList[appConfirmFieldIndex]["isShow"] = false;
          }
        });

        break;
    }
  }

  ionChange(item) {
    switch (this.businessObjectI.bomid) {
      case "T_HR_ChuChai":
        switch (item.fieldid) {
          case "appConfirm":
            switch (item.fvalue) {
              case "YES":
                let finishRadio = [{
                  code: "0",
                  exception: "",
                  isDefault: "0",
                  isSelAddr: "1",
                  msg: "成功！",
                  nodeName: "结束流程",
                  nodeType: "11",
                  numb: "67967"
                }];
                _.remove(this.workFlowParmeter["nextActivityDtos"], adto => {
                  return adto["numb"] === "67967";
                });
                this.workFlowParmeter["nextActivityDtos"] = _.concat(finishRadio,
                  this.workFlowParmeter["nextActivityDtos"]);
                this.flowParmeter.nextNodesRadio = finishRadio[0]["numb"];
                this.onNextNodeChange(this.flowParmeter.nextNodesRadio);
                break;
              case "NO":
                this.isInited = true;
                this.navCtrl.push(DraftDetailPage, {
                  ops: "update",
                  bosid: this.id,
                  type: "ccsq",
                  taskDetail: this.businessObjectDesList,
                  flowParmeter: this.flowParmeter,
                  businessObjectI: this.businessObjectI
                });
                break;
            }
            break;
        }
        break;
    }
  }

  initNextEditor() {
    let nextNode = {};
    switch (this.businessObjectI.bomid) {
      case "TPJ_FOS_LIQUIDATION":
        this.isGetNextEditorInTime = true;
        if (this.workFlowParmeter.flowWriteField.indexOf("ists") > -1) {
          this.detailService.getLIQUIDATIONNextEditor(this.businessObjectI["fundId"]).subscribe(nextEditor => {
            if (nextEditor) {
              this.empnames = nextEditor.empnames;
              this.empnamesId = nextEditor.loginids;
              this.flowParmeter.nextNodeEditor = nextEditor.defaultLoginids;
              this.flowParmeter.nextNodeEditorName = nextEditor.defaultEmpnames;
              this.initDefaultEmpByTree();
            }
          });
        }
        break;
      case "TPJ_FOS_YDDKFSS":
        this.isGetNextEditorInTime = true;
        if (this.workFlowParmeter.flowWriteField.indexOf("mrjjjl") > -1) {
          this.detailService.getFundPMInfo(this.id, this.businessObjectI.bomid, "").subscribe(nextEditor => {
            if (nextEditor) {
              this.empnames = nextEditor.empnames;
              this.empnamesId = nextEditor.loginids;
              this.flowParmeter.nextNodeEditor = nextEditor.defaultLoginids;
              this.flowParmeter.nextNodeEditorName = nextEditor.defaultEmpnames;
              this.initDefaultEmpByTree();
            }
          });
        }
        break;
      case "TPJ_FOS_ZHWYTC":
        this.isGetNextEditorInTime = true;
        if (this.workFlowParmeter.flowWriteField.indexOf("isSignDefaultPeople") > -1) {
          this.detailService.getFundPMInfo(this.id, this.businessObjectI.bomid, this.businessObjectI.fundCode)
            .subscribe(nextEditor => {
              if (nextEditor) {
                this.empnames = nextEditor.empnames;
                this.empnamesId = nextEditor.loginids;
                this.flowParmeter.nextNodeEditor = nextEditor.defaultLoginids;
                this.flowParmeter.nextNodeEditorName = nextEditor.defaultEmpnames;
                this.initDefaultEmpByTree();
              }
            });
        }
        break;
      default:
        this.initDefaultEmpByTree();
        break;
    }
  }

  initDefaultEmpByTree() {
    console.log("#########初始化组织树已选人员");
    if (this.isSelAddr === "1") {
      console.log("######允许从通讯录查询");
      this.storage.get("contact-user-list").then(u => {
        //构造通讯录用户对象
        console.log("nextNodeEditor", this.flowParmeter.nextNodeEditor);
        this.defaultEmpByTree = [];
        _.forEach(this.flowParmeter.nextNodeEditor, editor => {
          let user = _.find(u, {"loginid": editor});
          if (user) {
            let delfaultUser = {
              empid: user["empid"],
              loginid: user["loginid"],
              name: user["emname"],
              orgid: user["orgid"],
              titleid: user["titleid"],
              type: "user"
            };
            this.defaultEmpByTree.push(delfaultUser);
          }
        });
        console.log(this.defaultEmpByTree);
      });
    }
  }

  /**
   * 初始化关联事项显示
   */
  initRelatedMetters() {
    this.showRelatedMetters = {
      "fname": "关联事项审批",
      "dataType": "relatedMetters",
      "type": "relatedMetters",
      "isShow": this.flowControl["isNeedShowRelatedMetters"],
      "params": {},
      "titleField": []
    };
    let tempList = [];
    _.forEach(this.businessObjectDesList, b => {
      if (b.fname == "正文") {
        tempList.push(this.showRelatedMetters);
      }
      tempList.push(b);
    });
    this.businessObjectDesList = tempList;

    if (this.flowControl["needControl"]) {
      if (this.flowControl["isAllowUp"] != 1) {
        let alert = this.alertCtrl.create({
          title: "提示",
          message: "关联事项审批流程未完成审批",
          buttons: [
            {
              text: "确定",
              role: 'cancel',
              handler: () => {
              }
            }
          ]
        });
        alert.present();
      }
    }
  }

  /**
   * 查看关联事项详情
   */
  viewRelatedMetter(item) {
    if (item.isAllowPhoneView) {
      this.navCtrl.push(TaskDetailPage, {id: item.bosid, wkiType: "6"});
    } else {
      let alert = this.alertCtrl.create({
        title: "提示",
        message: "该流程暂未支持手机OA展示",
        buttons: [
          {
            text: "确定",
            role: 'cancel',
            handler: () => {
            }
          }
        ]
      });
      alert.present();
    }
  }

  /**
   * 初始化列表点击查看按钮
   */
  initViewListButton(bomid, bomname) {
    class multiListButtonClass {
      fname = "";
      dataType = "multiListButton";
      type = "multiListButton";
      isShow = false;
      params = {};
      titleField = [];
    }

    this.viewListButton = {
      "fname": "",
      "dataType": "listButton",
      "type": "listButton",
      "isShow": false,
      "params": {},
      "titleField": []
    };
    console.log(bomid);
    switch (bomid) {
      case 'TPJ_FOS_OPEN_JWZQZH'://[FOS]境外证券账户开户
        this.viewListButton.fname = "开户列表";
        this.viewListButton.isShow = true;
        this.viewListButton.params = {
          tableName: "TPJ_FOS_JWZQZH_DETIL",
          condition: "and glbosid='" + this.id + "'"
        };
        this.viewListButton.titleField = ["基金名称", "券商公司名称"];
        this.addViewListButton("正文");
        break;
      case 'TPJ_FOS_TBED'://套保额度申请
        this.viewListButton.fname = "申请列表";
        this.viewListButton.isShow = true;
        this.viewListButton.params = {
          tableName: "TPJ_FOS_TBED_DETAIL",
          condition: "and glbosid='" + this.id + "'"
        };
        this.viewListButton.titleField = ["额度类型", "买卖方向"];
        this.addViewListButton("正文");
        break;
      case 'TPJ_FOS_TZXTSQ'://[FOS]投资系统自由交易授权申请
        this.viewListButton.fname = "授权基金列表";
        this.viewListButton.isShow = true;
        this.viewListButton.params = {
          tableName: "TPJ_FOS_TZXTSQ_DETAIL",
          condition: "and glbosid='" + this.id + "'"
        };
        this.viewListButton.titleField = ["基金代码", "基金名称"];
        this.addViewListButton("正文");
        break;
      case 'TPJ_FOS_OPEN_TGZH'://[FOS]托管账户开户
        this.viewListButton.fname = "境内账户列表";
        this.viewListButton.isShow = true;
        this.viewListButton.params = {
          tableName: "TPJ_FOS_OPEN_JNTGZHMX",
          condition: "and glbosid='" + this.id + "'"
        };
        this.viewListButton.titleField = ["账户名称", "开户行名称"];
        this.addViewListButton("正文");
        if (this.businessObjectI["Abroad"] == "2") {
          this.viewListButton = {
            "fname": "境外账户列表",
            "dataType": "jwtgListButton",
            "type": "jwtgListButton",
            "isShow": true,
            "params": {
              tableName: "TPJ_FOS_OPEN_JWTGZHMX",
              condition: "and glbosid='" + this.id + "'"
            },
            "titleField": ["境外账户名称", "境外开户行名称"]
          };
          this.addViewListButton("正文");
        }
        let abroad = _.find(this.businessObjectDesList, {fieldid: "Abroad"});
        if (abroad) {
          let index = this.businessObjectDesList.indexOf(abroad);
          if (this.businessObjectI["Abroad"] == "2") {
            this.businessObjectDesList[index].fvalue = "是";
          } else {
            this.businessObjectDesList[index].fvalue = "否";
          }
        }
        break;
      case 'TPJ_FOS_SEAT_RENT'://[FOS]席位租用
        this.viewListButton.fname = "席位信息";
        this.viewListButton.isShow = true;
        this.viewListButton.params = {
          tableName: "TPJ_FOS_SEAT_RENT_detail",
          condition: "and glbosid='" + this.id + "'"
        };
        this.viewListButton.titleField = ["市场", "席位号"];
        this.addViewListButton("备注");
        break;
      case 'TPJ_FOS_YDDKFSS'://[FOS]一对多专户产品开放申赎
        this.viewListButton.fname = "产品列表";
        this.viewListButton.isShow = true;
        this.viewListButton.params = {
          tableName: "TPJ_FOS_YDDKFSS_MX",
          condition: "and glbosid='" + this.id + "'"
        };
        this.viewListButton.titleField = ["基金代码", "基金名称"];
        this.addViewListButton("正文");
        break;
      case 'TPJ_FOS_SEAT_CHANGE'://[FOS]席位协议变更
        this.viewListButton.fname = "席位信息";
        this.viewListButton.isShow = true;
        this.viewListButton.params = {
          tableName: "TPJ_FOS_SEAT_CHANGE_DETAIL",
          condition: "and glbosid='" + this.id + "'"
        };
        this.viewListButton.titleField = ["适用产品", "席位号"];
        this.addViewListButton("备注");
        break;
      case 'TPJ_FOS_SEAT_RETURN'://[FOS]席位退租
        this.viewListButton.fname = "席位信息";
        this.viewListButton.isShow = true;
        this.viewListButton.params = {
          tableName: "TPJ_FOS_SEAT_RETURN_DETAIL",
          condition: "and glbosid='" + this.id + "'"
        };
        this.viewListButton.titleField = ["券商", "席位号"];
        this.addViewListButton("备注");
        break;
      case 'TPJ_FOS_ZQCYRTP'://[FOS]债券持有人会议投票流程
        this.viewListButton.fname = "基金列表";
        this.viewListButton.isShow = true;
        this.viewListButton.params = {
          tableName: "TPJ_FOS_ZQCYRTP_MX",
          condition: "and glbosid='" + this.id + "'"
        };
        this.viewListButton.titleField = ["基金代码", "基金简称"];

        this.storage.get("userInfo").then(user => {
          console.log(user);
          console.log(this.workFlowParmeter.flowCurrEditor.indexOf(user.loginid));
          if (this.workFlowParmeter.flowCurrNode == "基金经理确认"
            && this.workFlowParmeter.flowCurrEditor.indexOf(user.loginid) > -1) {
            this.viewListButton.params.condition += " and managerid like '%" + user.empid + "%'";
          }
        });

        this.addViewListButton("正文");
        break;
      case 'T_HR_ChuJingSQ'://出境申请
        this.viewListButton.fname = "请假列表";
        this.viewListButton.isShow = false;
        let index = _.findIndex(this.businessObjectDesList, {fieldid: "chujingWhy"});
        if (this.businessObjectDesList[index].fvalue == "1") {
          this.viewListButton.isShow = true;
        }
        this.viewListButton.params = {
          tableName: "t_hr_jiazhongsd,tpj_chujing_mx",
          condition: "and glbosid='" + this.id + "' and bosid=qjtype"
        };
        this.viewListButton.titleField = ["请假类型", "请假天数"];
        this.addViewListButton("出境事由");
        break;
      case 'T_HR_ChuChai':
        this.viewListButton.fname = "出差明细";
        this.viewListButton.isShow = true;
        let dytype_index = _.findIndex(this.businessObjectDesList, {fieldid: "dytype"});
        console.log(this.businessObjectDesList[dytype_index]);
        if (this.businessObjectDesList[dytype_index]["fvalue"] === "1") {
          this.viewListButton.params = {
            tableName: "T_HR_ChuChai_DETAILS_study",
            condition: "and glbosid='" + this.id + "'"
          };
        } else {
          this.viewListButton.params = {
            tableName: "T_HR_ChuChai_DETAILS_normal",
            condition: "and glbosid='" + this.id + "'"
          };
        }
        console.log(this.viewListButton);

        this.viewListButton.titleField = ["开始日期", "结束日期"];
        this.addViewListButton("部门负责人审批");
        break;
      case 'TPJ_FOS_JYDSKTZ'://交易对手库调整
        let optGroup = this.businessObjectI["tzfsId"].split(",");
        if (optGroup && optGroup.length > 0) {
          this.viewListButton["type"] = "multiListButton";
          this.viewListButton["isShow"] = true;
          this.viewListButton["buttons"] = [];
          _.forEach(optGroup, opt => {
            let multiListButton = new multiListButtonClass();
            switch (opt) {
              case "add":
                //新增列表
                multiListButton.fname = "新增列表信息";
                multiListButton.isShow = true;
                multiListButton.params = {
                  tableName: "tpj_fos_jydsktz_detail_add",
                  condition: "and glbosid='" + this.id + "' and listtype = 'add'"
                };
                multiListButton.titleField = ["交易对手", "业务分类"];
                this.viewListButton.buttons.push(multiListButton);
                break;
              case "del":
                //删除列表
                multiListButton.fname = "删除列表信息";
                multiListButton.isShow = true;
                multiListButton.params = {
                  tableName: "tpj_fos_jydsktz_detail_del",
                  condition: "and glbosid='" + this.id + "' and listtype = 'del'"
                };
                multiListButton.titleField = ["交易对手", "业务分类"];
                this.viewListButton.buttons.push(multiListButton);
                break;
              case "update":
                multiListButton.fname = "调整列表信息";
                multiListButton.isShow = true;
                multiListButton.params = {
                  tableName: "tpj_fos_jydsktz_detail_update",
                  condition: "and glbosid='" + this.id + "' and listtype = 'update'"
                };
                multiListButton.titleField = ["交易对手", "业务分类"];
                this.viewListButton.buttons.push(multiListButton);
                break;
            }
          });
          this.addViewListButton("正文");
        }
        break;
      case "TPJ_FOS_XSDLXY":
        this.viewListButton["type"] = "multiListButton";
        this.viewListButton["isShow"] = true;
        this.viewListButton["buttons"] = [];
        switch (this.businessObjectI["flowTypeId"]) {
          case "01":
            let multiListButton_01 = new multiListButtonClass();
            //销售框架协议列表
            multiListButton_01.fname = "销售框架协议列表";
            multiListButton_01.isShow = true;
            multiListButton_01.params = {
              tableName: "tpj_fos_xsdlxy_detail_01",
              condition: "and glbosid = '" + this.id + "' and flowtypeid = '01'"
            };
            multiListButton_01.titleField = ["销售机构", "渠道归属部门"];
            this.viewListButton.buttons.push(multiListButton_01);
            break;
          case "02":
            let multiListButton_02 = new multiListButtonClass();
            //机构信息列表
            multiListButton_02.fname = "机构信息列表";
            multiListButton_02.isShow = true;
            multiListButton_02.params = {
              tableName: "tpj_fos_xsdlxy_detail_jginfo_02",
              condition: "and glbosid = '" + this.id + "' and flowtypeid = '02'"
            };
            multiListButton_02.titleField = ["销售机构", "直销网点"];
            this.viewListButton.buttons.push(multiListButton_02);
            //历史协议列表
            multiListButton_02 = new multiListButtonClass();
            multiListButton_02.fname = "历史协议列表";
            multiListButton_02.isShow = true;
            multiListButton_02.params = {
              tableName: "tpj_fos_xsdlxy_detail_02",
              condition: "and glbosid = '" + this.id + "' and flowtypeid = '02_before'"
            };
            multiListButton_02.titleField = ["销售机构", "渠道归属部门"];
            this.viewListButton.buttons.push(multiListButton_02);
            //续签协议列表
            multiListButton_02 = new multiListButtonClass();
            multiListButton_02.fname = "续签协议列表";
            multiListButton_02.isShow = true;
            multiListButton_02.params = {
              tableName: "tpj_fos_xsdlxy_detail_01",
              condition: "and glbosid = '" + this.id + "' and flowtypeid = '02_after'"
            };
            multiListButton_02.titleField = ["销售机构", "渠道归属部门"];
            this.viewListButton.buttons.push(multiListButton_02);
            break;
          case "03":
            let multiListButton_03 = new multiListButtonClass();
            //销售补充协议列表
            multiListButton_03.fname = "销售补充协议列表";
            multiListButton_03.isShow = true;
            multiListButton_03.params = {
              tableName: "tpj_fos_xsdlxy_detail_03",
              condition: "and glbosid = '" + this.id + "' and flowtypeid = '03'"
            };
            multiListButton_03.titleField = ["基金名称", "销售机构"];
            this.viewListButton.buttons.push(multiListButton_03);
            break;
          case "04":
            let multiListButton_04 = new multiListButtonClass();
            //机构信息列表
            multiListButton_04.fname = "机构信息列表";
            multiListButton_04.isShow = true;
            multiListButton_04.params = {
              tableName: "tpj_fos_xsdlxy_detail_jginfo_04",
              condition: "and glbosid = '" + this.id + "' and flowtypeid = '04'"
            };
            multiListButton_04.titleField = ["基金名称", "销售机构"];
            this.viewListButton.buttons.push(multiListButton_04);
            //历史协议列表
            multiListButton_04 = new multiListButtonClass();
            multiListButton_04.fname = "历史协议列表";
            multiListButton_04.isShow = true;
            multiListButton_04.params = {
              tableName: "tpj_fos_xsdlxy_detail_04",
              condition: "and glbosid = '" + this.id + "' and flowtypeid = '04_before'"
            };
            multiListButton_04.titleField = ["基金名称", "销售机构"];
            this.viewListButton.buttons.push(multiListButton_04);
            //续签协议列表
            multiListButton_04 = new multiListButtonClass();
            multiListButton_04.fname = "续签协议列表";
            multiListButton_04.isShow = true;
            multiListButton_04.params = {
              tableName: "tpj_fos_xsdlxy_detail_03",
              condition: "and glbosid = '" + this.id + "' and flowtypeid = '04_after'"
            };
            multiListButton_04.titleField = ["基金名称", "销售机构"];
            this.viewListButton.buttons.push(multiListButton_04);
            break;
        }
        this.addViewListButton("正文");
        break;
      case "TPJ_FOS_BG_TGZH":
        this.viewListButton["type"] = "multiListButton";
        this.viewListButton["isShow"] = true;
        this.viewListButton["buttons"] = [];
        //境内托管信息
        let multiListButton1 = new multiListButtonClass();
        multiListButton1.fname = "境内托管信息";
        multiListButton1.isShow = true;
        multiListButton1.params = {
          tableName: "TPJ_FOS_BG_JNTGZHMX",
          condition: "and glbosid='" + this.id + "'"
        };
        multiListButton1.titleField = ["账号", "账号名称"];
        this.viewListButton.buttons.push(multiListButton1);
        //境外外托管信息
        let secBtn: any = _.find(this.businessObjectDesList, {"fieldid": "AbroadName"});
        console.log(secBtn);
        if (secBtn.fvalue === "是") {
          let multiListButton2 = new multiListButtonClass();
          multiListButton2.fname = "境外托管信息";
          multiListButton2.isShow = true;
          multiListButton2.params = {
            tableName: "TPJ_FOS_BG_JWTGZHMX",
            condition: "and glbosid='" + this.id + "'"
          };
          multiListButton2.titleField = ["账号", "账号名称"];
          this.viewListButton.buttons.push(multiListButton2);
        }
        this.addViewListButton("正文");
        break;
      case "TPJ_FOS_GZWYJY":
        this.viewListButton.fname = "基金列表";
        this.viewListButton.isShow = true;
        this.viewListButton.params = {
          tableName: "TPJ_FOS_GZWYJY_GLMX",
          condition: "and refbosid='" + this.id + "'"
        };
        this.viewListButton.titleField = ["基金代码", "基金名称"];
        this.addViewListButton("估值调整方案");
        break;
    }
  }

  addViewListButton(fname) {
    let tempList = [];
    _.forEach(this.businessObjectDesList, b => {
      if (b.fname == fname) {
        tempList.push(this.viewListButton);
      }
      tempList.push(b);
    });
    this.businessObjectDesList = tempList;

    console.log(this.businessObjectDesList);
  }

  /**
   * [onNextNodeChange 选择下一节点,重新初始化下一节处理人]
   * @param {[type]} numb [下一节点ID]
   */
  onNextNodeChange(numb) {
    if (this.nextNodeNum === numb) {
      return false;
    }
    console.log("##下一节点ID：" + numb);
    this.empnames = [];
    this.empnamesId = [];
    this.flowParmeter.nextNodeEditorName = [];
    this.flowParmeter.nextNodeEditor = [];
    this.defaultEmpByTree = [];

    var node: any = _.find(this.workFlowParmeter.nextActivityDtos, {"numb": numb}); // 选择的节点
    //console.log(node);
    this.isSelAddr = node.isSelAddr;
    this.nextNodeNum = node.numb;

    if (node) {
      this.initDefaultEmpByTree();

      if (["67494", "63011", "66846"].indexOf(numb) > -1 && this.isGetNextEditorInTime) {
        this.initNextEditor();
      }

      let participantDtos = node.participantDtos; // 人员节点

      //flowCurrNode不传下一处理节点
      // this.flowParmeter.flowCurrNode = node.nodeName;
      this.flowParmeter.flowCurrNode = this.workFlowParmeter.flowCurrNode;
      this.nextNodeType = node.nodeType;

      if (_.map(participantDtos, "empnames")[0]) {
        this.empnames = _.flattenDeep(_.map(participantDtos, "empnames")); // 人员数组
        this.empnamesId = _.flattenDeep(_.map(participantDtos, "loginIds")); // 人员ID数组
        if (this.empnames) {
          this.empnames = _.uniq(this.empnames);//人员数组去重
          console.log(this.empnames);
        }
        if (this.empnamesId) {
          this.empnamesId = _.uniq(this.empnamesId);//人员ID数组去重
        }
      }


      //console.log("####################");
      //console.log(node)
      // console.log(participantDtos);
      // console.log(this.empnames);
      // console.log(this.empnamesId);

      // 获取有设置默认人员的节点 1：有，0：没有
      var fNode = _.filter(participantDtos, {"isDefault": 1});

      // 没有设置默认人员节点并且第一个人员节点只有一个人，则选择第一个人员节点
      if (fNode.length == 0) {
        if (node.nodeType == "03") { // 会签节点特殊处理
          if (participantDtos && participantDtos[0].length == 1) {
            fNode = _.concat(fNode, participantDtos[0]);
          }
        } else {
          if (participantDtos && participantDtos[0].empnames && participantDtos[0].empnames.length == 1) {
            fNode = _.concat(fNode, participantDtos[0]);
          }
        }

      }

      if (fNode) {
        let names = _.flattenDeep(_.map(fNode, "empnames")); // 人员
        let loginids = _.flattenDeep(_.map(fNode, "loginIds")); // 人员ID
        if (this.nextNodeType == "02" && names.length > 1) { // 如果是普通节点（单选节点），默认选择人员有多个，则默认不选择；
          this.flowParmeter.nextNodeEditorName = [];
          this.flowParmeter.nextNodeEditor = [];
        } else {// 只有一个人默认选择
          //过滤下一个节点处理人为undefined的bug
          this.flowParmeter.nextNodeEditorName = _.filter(names, n => n && true);
          this.flowParmeter.nextNodeEditor = _.filter(loginids, n => n && true);
        }
        //默认下一处理人以及预置人员去重
        this.flowParmeter.nextNodeEditor = _.uniq(this.flowParmeter.nextNodeEditor);
        this.flowParmeter.nextNodeEditorName = _.uniq(this.flowParmeter.nextNodeEditorName);
      }
    }
  }

  /**
   * 选择下一节点处理人
   */
  chooseFlowEmp() {
    let that = this;
    // 普通节点和转办节点单选，其他其他节点类型多选
    let isSelectOne = (this.nextNodeType == "02" || this.nextNodeNum == "switchBtn") ? true : false;
    // 有提供默认的选择人员时在默认人员肿选择，如果没有提供默人员则在组织树选择
    if (this.empnames.length > 0) {
      if (this.isSelAddr === "1") {//允许从通讯录选择下一处理人

        if (this.nextNodeNum == "switchBtn") { // 下一节点处理人列表 ：转办
          let parmas = {
            selected: this.defaultEmpByTree,
            isSelectUser: true,
            isSelectOne: isSelectOne,
            "isSelAddr": this.isSelAddr,
            "empnames": this.empnames,
            "empnamesId": this.empnamesId,
            "defaultEmpnames": this.flowParmeter.nextNodeEditorName,
            "defaultEmpnamesId": this.flowParmeter.nextNodeEditor
          };
          console.log("params", parmas);
          this.detailService.getReorgidsByOrgid(this.orgidWhileSwtich).subscribe(data => { // 获得父部门ID
            if (data && data != "0") {
              parmas["reorgid"] = data;
              parmas["orgid"] = this.orgidWhileSwtich;
              parmas["titleid"] = null;

            }

            let modal = this.modalCtrl.create(ContactChoosePage, parmas);
            modal.present();
            modal.onWillDismiss((data: any[]) => {
              //console.info(data);
              if (data) {
                that.defaultEmpByTree = data;
                that.flowParmeter.nextNodeEditorName = _.map(data, "name");
                that.flowParmeter.nextNodeEditor = _.map(data, "loginid");
              }
            });

          });
        } else {//非转办
          let parmas = {
            selected: this.defaultEmpByTree,
            isSelectOne: isSelectOne,
            isSelectUser: true,
            "isSelAddr": this.isSelAddr,
            "empnames": this.empnames,
            "empnamesId": this.empnamesId,
            "defaultEmpnames": this.flowParmeter.nextNodeEditorName,
            "defaultEmpnamesId": this.flowParmeter.nextNodeEditor
          };
          //console.log("#############39")
          let modal = this.modalCtrl.create(ContactChoosePage, parmas);
          modal.present();
          modal.onWillDismiss((data: any[]) => {
            //console.info(data);
            if (data) {
              that.defaultEmpByTree = data;
              that.flowParmeter.nextNodeEditorName = _.map(data, "name");
              that.flowParmeter.nextNodeEditor = _.map(data, "loginid");
            }
          });
        }
      } else {//不允许从通讯录选择下一处理人
        let modal = this.modalCtrl.create(EmpPage, {
          "isSelectOne": isSelectOne,
          "isSelAddr": this.isSelAddr,
          "empnames": this.empnames, "empnamesId": this.empnamesId,
          "defaultEmpnames": this.flowParmeter.nextNodeEditorName,
          "defaultEmpnamesId": this.flowParmeter.nextNodeEditor
        });
        modal.present();

        modal.onWillDismiss((data: any) => {
          if (data) {
            //console.log(data);
            that.flowParmeter.nextNodeEditorName = data.defaultEmpnames;
            that.flowParmeter.nextNodeEditor = data.defaultEmpnamesId;
            //console.info("##返回的人员ID:" + that.flowParmeter.nextNodeEditor);
          }
        });
      }
    } else {
      let parmas = {
        selected: this.defaultEmpByTree,
        isSelectUser: true,
        isSelectOne: isSelectOne
      };
      if (this.nextNodeNum == "switchBtn") { // 下一节点处理人列表 ：转办
        this.detailService.getReorgidsByOrgid(this.orgidWhileSwtich).subscribe(data => { // 获得父部门ID
          if (data && data != "0") {
            parmas["reorgid"] = data;
            parmas["orgid"] = this.orgidWhileSwtich;
            parmas["titleid"] = null
          }

          let modal = this.modalCtrl.create(ContactChoosePage, parmas);
          modal.present();
          modal.onWillDismiss((data: any[]) => {
            //console.info(data);
            if (data) {
              that.defaultEmpByTree = data;
              that.flowParmeter.nextNodeEditorName = _.map(data, "name");
              that.flowParmeter.nextNodeEditor = _.map(data, "loginid");
            }
          });

        });
      } else { // 下一节点处理人列表  ：非转办
        let parmas = {
          selected: this.defaultEmpByTree,
          isSelectOne: isSelectOne,
          isSelectUser: true,
          //isSelAddr: this.isSelAddr
          // reorgid: null,
          // orgid: null,
          // titleid: null
        }
        //console.log("#############39")
        let modal = this.modalCtrl.create(ContactChoosePage, parmas);
        modal.present();
        modal.onWillDismiss((data: any[]) => {
          //console.info(data);
          if (data) {
            that.defaultEmpByTree = data;
            that.flowParmeter.nextNodeEditorName = _.map(data, "name");
            that.flowParmeter.nextNodeEditor = _.map(data, "loginid");
          }
        });
      }


    }
  }

  /**
   * [update 通用流程]
   * @param {[type]} type [提交类型，0、收回；1、提交沟通意见;2、提交；3、表决同意；4、驳回；5、驳回起草人；6、终止流程；
   * 7、表决不同意；8、结束沟通 20、退回任意节点]
   */
  update(type) {
    this.flowParmeter.flowHandleType = type;
    this.flowParmeter.flowAppointNodeSel = null;
    this.flowParmeter.flowSendReads = null;
    this.flowParmeter.bostitle = this.businessObjectI.bostitle;
    this.flowParmeter.bomid = this.businessObjectI.bomid;
    this.flowParmeter.bid = this.id;
    this.flowParmeter.loginId = this.loginid;
    this.flowParmeter.wkPrdid = null;
    this.flowParmeter.isOther = false;
    this.flowParmeter.variableMap = null;
    this.flowParmeter.indirectNodeMap = null;
    //--意见附加
    this.flowParmeter.flowOldNotion = "";
    if (this.workFlowParmeter.flownotioninputstyle && this.workFlowParmeter.flownotioninputstyle == 2) {
      this.flowParmeter.flowOldNotion = this.businessObjectI[this.workFlowParmeter.flownotionField];
    }
    this.flowParmeter.clientType = this.common.getClientType(); // 获取手机类型 android or iphone
    this.flowParmeter.flowOrgTitSel = null; // 人员没有多部门，设置空

    this.detailService.updateInstance(this.flowParmeter).subscribe(data => {
      if (data.msg == "成功！" && data.code == "0") {
        // 广播刷新列表
        if (type == "0") { // 收回
          this.events.publish("task-detail: take back", {"bid": this.id});
          this.events.publish("task-detail: take back-main", {"bid": this.id});
        } else if (this.flowParmeter.nextNodesRadio != 'startCmBtn' && !this.workFlowParmeter.isEndCm) { // 如果不是启用沟通或结束沟通
          this.events.publish("task-detail:toBeDeal,todo,deal has updated", {"bid": this.id});
          this.events.publish("task-detail:todo,deal has updated", {"bid": this.id});
        }

        if ( (type === "5" || type === "6") && (this.businessObjectI["bomid"] === "T_HR_QingJia"
          || this.businessObjectI["bomid"] === "T_HR_ChuJingSQ") ) {
            this.detailService.finDeductHrAnnualDay(this.id).subscribe(deleteResult => {
              console.log("删除预扣减天数>>>>>>>>>>>>.", deleteResult);
            });
        }

        // console.log("收回到起草节点", type, this.workFlowParmeter.flowPrevNode);
        if (type === "0" && (this.businessObjectI["bomid"] === "T_HR_QingJia"
          || this.businessObjectI["bomid"] === "T_HR_ChuJingSQ") ) {
          if ((this.workFlowParmeter.flowPrevNode.indexOf("起始节点") > -1
            || this.workFlowParmeter.flowPrevNode.indexOf("起草") > -1)) {
            this.detailService.finDeductHrAnnualDay(this.id).subscribe(deleteResult => {
              console.log("收回到起草节点时删除预扣减天数>>>>>>>>>>>>.", deleteResult);
            });
          }
        }

        console.log(this.businessObjectI["bomid"]);
        console.log(this.flowParmeter["flowCurrNode"]);
        if (this.businessObjectI["bomid"] === "zjhb" && this.flowParmeter["flowCurrNode"] === "风险管理部初步审核") {
          console.log("1231231风险管理初步审核");
          this.doPushBTA();
        } else {
          this.navCtrl.pop(); // 提交成功，pop掉当前view,即返回列表
        }
      } else {
        let alert = this.alertCtrl.create({ // 有异常信息，弹出提示
          title: "异常信息提示",
          message: data.exception,
          buttons: [
            {
              text: "确定",
              role: 'cancel',
              handler: () => {
                //console.log('Cancel clicked');
              }
            }
          ]
        });
        alert.present();
      }
    })
  }

  doPushBTA() {
    console.log("推送BTA");
    let errorMsg = [];
    if (this.attachs && this.attachs[0]) {
      _.forEach(this.attachs[0].datas, (attach, i) => {
        console.log(attach);
        if (attach.title.indexOf("资金划拨表") > -1) {
          this.detailService.pushBTA(this.id, attach["num"]).subscribe(result => {
            console.log("推送BTA");
            console.log(result);
            if (result && result[0]) {
              if (result[0]["l_err_code"] == "0") {

              } else {
                errorMsg.push("文件：" + attach["title"] + " 推送失败");
              }
            } else {
              errorMsg.push("文件：" + attach["title"] + " 推送失败");
            }
          });
        } else {
          this.navCtrl.pop();
          return;
        }
      });
      console.log(errorMsg);
      if (errorMsg.length > 0) {
        _.forEach(this.backupBusinessObjectDesList, bus => {
          if (bus.fieldid == "pushstatus") {
            bus.fvalue = "2";
          }
          if (bus.fieldid == "push") {
            bus.fvalue = "2";
          }
        });

        let entrys = this.formateBusinessObjectDes(this.backupBusinessObjectDesList);
        this.detailService.updateBusinessObjectDes(this.id, entrys).subscribe(doResult => {
          console.log("更新业务对象字段");
          console.log(doResult);
          if (doResult.code == "0") {
            // this.navCtrl.pop();
          }
        });

        let alert = this.alertCtrl.create({
          title: "提示",
          message: _.toString(errorMsg),
          buttons: [
            {
              text: "确定",
              role: 'cancel',
              handler: () => {
                this.navCtrl.pop();
              }
            }
          ]
        });
        alert.present();
        return false;
      } else {
        _.forEach(this.backupBusinessObjectDesList, bus => {
          if (bus.fieldid == "pushstatus") {
            bus.fvalue = "1";
          }
          if (bus.fieldid == "push") {
            bus.fvalue = "1";
          }
        });
        let entrys = this.formateBusinessObjectDes(this.backupBusinessObjectDesList);
        this.detailService.updateBusinessObjectDes(this.id, entrys).subscribe(doResult => {
          console.log("更新业务对象字段");
          console.log(doResult);
          if (doResult.code == "0") {
            this.navCtrl.pop();
          }
        });
        return true;
      }
    } else {
      this.navCtrl.pop();
    }
  }

  /**
   * [formateBusinessObjectDes 格式化businessObjectDesList，主要用于调用insert接口]
   * @param {[type]} businessObjectDesList [description]
   */
  formateBusinessObjectDes(businessObjectDesList) {
    console.log("draft.service.formateBusinessObjectDes:格式化businessObjectDesList，以便调用接口插入");
    var that = this;
    var entrys = [];
    // 构建节点
    _.forEach(businessObjectDesList, function (data) {
      let temp = {
        "key": {
          "attributes": that.common.attributes,
          "$value": ""
        },

        "value": {
          "attributes": that.common.attributes,
          "$value": ""
        }
      };
      temp.key.$value = data["fieldid"];
      temp.value.$value = data["fvalue"];
      entrys.push(temp);
    });

    // 追加bomid
    let bomid = {
      "key": {
        "attributes": that.common.attributes,
        "$value": "bomid"
      },
      "value": {
        "attributes": that.common.attributes,
        "$value": this.businessObjectI["bomid"]
      }
    };
    // 追加dirid
    let dirid = {
      "key": {
        "attributes": that.common.attributes,
        "$value": "dirid"
      },
      "value": {
        "attributes": that.common.attributes,
        "$value": this.businessObjectI["dirid"]
      }
    };
    entrys.push(bomid);
    entrys.push(dirid);
    return entrys;
  }

  /**
   * [updateInfo 提交通知公告发布、驳回]
   * @param {[type]} type [publish 发布，reject 驳回]
   * @param {[type]} needNotice [YES 发布时需要送阅，NO 发布时不用送阅]
   */
  updateInfo(type, needNotice) {
    var params = {
      "type": "",
      "bid": "",
      //"bomid": "t_info_Doc",
      "loginId": "",
      "msmodel": "", // update
      "wkiState": "", // publish 8 reject 1
      //"wkiProName": "信息中心",
      "wkiUser": "", // 后端需要处理
      "wkiTitle": "",
      //"isOther": false,
      "shjl": "",
      "refen": "",
      "refenDtos": {
        "skey": [],
        "svalue": []
      },
      "needNotice": needNotice

    }

    let flowNotion = this.flowParmeter.flowNotion ? this.flowParmeter.flowNotion : ""; // 审核意见
    params.type = type;
    params.bid = this.id;
    params.loginId = this.loginid;
    params.msmodel = this.businessObjectI.isMsg == "YES" ? "SY" : "";
    params.wkiState = type == "publish" ? "8" : "1";
    if (type == "publish") {// 发布
      params.wkiUser = _.trim(this.businessObjectI.readCont) ? _.trim(this.businessObjectI.readCont) : "OU=gffunds";
    } else {// 驳回
      params.wkiUser = this.businessObjectI.empid;
    }
    params.wkiTitle = this.businessObjectI.bostitle;
    params.shjl = "<br>" + this.emname + ":<br>" + flowNotion + "<span style='color:red'>(来自" + this.common.getClientType() + ")</span>"
      + "[" + this.common.getTime(0) + "]" + this.businessObjectI.shjl;
    params.refen = "[wkiState]" + params.wkiState + "::[wkiProName]" + "信息中心";

    params.refenDtos.skey = ["wkiState", "wkiProName"];
    params.refenDtos.svalue = [params.wkiState, "信息中心"]

    params["readCont"] = this.businessObjectI["readCont"];
    params["readContName"] = this.businessObjectI["readContName"];
    params["isMsg"] = this.businessObjectI["isMsg"];

    params["selectedLoginid"] = this.selectedLoginid;
    params["selectedOrgid"] = this.selectedOrgid;
    params["selectedTitleid"] = this.selectedTitleid;

    this.detailService.updateInfoInstance(params).subscribe(data => {
      if (data && data.msg == "成功！" && data.code == "0") {
        // 广播刷新列表
        this.events.publish("task-detail:toBeDeal,todo,deal has updated", {"bid": this.id});
        this.events.publish("task-detail:todo,deal has updated", {"bid": this.id});

        this.navCtrl.pop(); // 提交成功，pop掉当前view,即返回列表
      } else {
        let alert = this.alertCtrl.create({ // 有异常信息，弹出提示
          title: "异常信息提示",
          message: data.exception,
          buttons: [
            {
              text: "确定",
              role: 'cancel',
              handler: () => {
                //console.log('Cancel clicked');
              }
            }
          ]
        });
        alert.present();
      }
    })

  }

  /**
   * [checkConfirmData 流程提交，校验数据]
   * @param {[type]} type [description]
   */
  checkConfirmData(type) {
    let retVal: any = {
      result: true, // 是否校验通过
      message: "" // 提示信息
    };
    // console.log(this.flowParmeter.nextNodesRadio);
    // console.log(type);
    // console.log(this.workFlowParmeter.refen);
    // 校验选择的节点是否允许在手机端做提交操作, '提交'、'办理结束交办'、'交办'不允许在手机端做提交操作
    if (type == "1" && _.includes(this.workFlowParmeter.refen, "[ISALLOWPHONEHANDLE]NO")) { // 提交
      this.storage.get("userInfo").then(user => {
        if (user) {
          let index = this.workFlowParmeter.cmEditors.indexOf(user.loginid);
          if (index == -1) {
            retVal.result = false;
            retVal.message = "该流程节点不允许在手机端操作，请在PC端进行流程操作！";
          } else {
            retVal.result = true;
            retVal.message = "";
          }
          return retVal;
        }
      });
    }

    if (type == "2" && (this.workFlowParmeter.flowCurrNodeType == 11 || this.nextNodeType == 11)
      && _.includes(this.workFlowParmeter.refen, "[ISALLOWPHONEHANDLE]NO")) { // 办理结束交办
      retVal.result = false;
      retVal.message = "该流程节点不允许在手机端操作，请在PC端进行流程操作！";
      return retVal;
    }

    if (type == "2" && !(this.workFlowParmeter.flowCurrNodeType == 11 || this.nextNodeType == 11)
      && this.flowParmeter.nextNodesRadio != 'startCmBtn'
      && this.flowParmeter.nextNodesRadio != 'switchBtn'
      && _.includes(this.workFlowParmeter.refen, "[ISALLOWPHONEHANDLE]NO")) { // 交办
      retVal.result = false;
      retVal.message = "该流程节点不允许在手机端操作，请在PC端进行流程操作！";
      return retVal;
    }


    // 数据非空校验
    if (type == '2' && this.nextNodeType != "11") {
      if (this.businessObjectI["bomid"] === "T_HR_ChuChai" && this.flowParmeter["flowCurrNode"] === "申请人确认") {
        let appConfirmFieldIndex = _.findIndex(this.businessObjectDesList, {fieldid: "appConfirm"});
        if (this.businessObjectDesList[appConfirmFieldIndex]["fvalue"] === "") {
          retVal.result = false;
          retVal.message = "请选择申请人确认";
          return retVal;
        }
      } else {
        if (_.trim(_.toString(this.flowParmeter.nextNodeEditor)) == "") {
          retVal.result = false;
          retVal.message = "请选择您要提交的后续办理人！";
          return retVal;
        }
      }
    }

    if (type == '2' && this.flowParmeter.nextNodesRadio == 'switchBtn') {
      if (_.trim(_.toString(this.flowParmeter.nextNodeEditor)) == "") {
        retVal.result = false;
        retVal.message = "请选择您要转交的文件办理人！";
        return retVal;
      }
    }

    if (type == "0") {
      if (_.trim(this.flowParmeter.flowCountermandNotion) == "") {
        retVal.result = false;
        retVal.message = "请您填写收回原因！";
        return retVal;
      }
    }

    if (type == '2' && this.flowParmeter.nextNodesRadio == 'startCmBtn') {
      if (this.businessObjectI["bomid"] === "T_HR_ChuChai" && this.flowParmeter["flowCurrNode"] === "申请人确认") {
        let appConfirmFieldIndex = _.findIndex(this.businessObjectDesList, {fieldid: "appConfirm"});
        if (this.businessObjectDesList[appConfirmFieldIndex]["fvalue"] === "") {
          retVal.result = false;
          retVal.message = "请选择申请人确认";
          return retVal;
        }
      } else {
        if (_.indexOf(this.flowParmeter.nextNodeEditor, this.loginid) > -1) {
          retVal.result = false;
          retVal.message = "启动沟通不能选择自己，请重新选择！";
          return retVal;
        }
      }
    }

    if (type == "reject") {
      if (_.trim(this.flowParmeter.flowNotion) == "") {
        retVal.result = false;
        retVal.message = "请您填写审核意见！";
        return retVal;
      }
    }

    return retVal;
  }

  /**
   * [alertMessage 根据不同的提交类型，显示提示信息]
   * @param {[type]} type [提交类型]
   */
  alertMessage(type) {
    let message = "确认要提交吗?";
    if (type == 0) {// 收回-
      message = "您确定要收回已经提交的审批文件吗？";
    } else if (type == 2 && (this.workFlowParmeter.flowCurrNodeType == 11 || this.nextNodeType == 11)) { // 办理结束
      message = "您确定要结束该流程文件的办理吗？";
    } else if (type == 2 && this.flowParmeter.nextNodesRadio == 'startCmBtn') { // 启动沟通-
      message = "您确定要提交文件给'" + this.flowParmeter.nextNodeEditorName + "'进行沟通交流吗？";
    } else if (type == 2 && this.flowParmeter.nextNodesRadio == 'switchBtn') { // 转办
      message = "您确定要转交文件给'" + this.flowParmeter.nextNodeEditorName + "'进行办理吗？";
    } else if (type == 2) { // 交办-
      let tempNextNode = _.find(this.workFlowParmeter.nextActivityDtos, {numb: this.flowParmeter.nextNodesRadio});
      message = "您确定要提交文件到'" + tempNextNode["nodeName"] + "'" + "节点并交给'" + this.flowParmeter.nextNodeEditorName + "'进行处理吗？";
    } else if (type == 3) { // 表决同意
      // TODO: 旧版的手机端没有这个业务
    } else if (type == 4) { // 退回
      message = "您确定要把文件退回给上一个处理人员重新办理吗？";
    } else if (type == 5) { // 驳回起草人-
      message = "您确定要把文件退回给起草人重新办理吗？";
    } else if (type == 6) { // 终止流程
      message = "您确定要终止文件的审批吗？";
    } else if (type == 7) { // 表决不同意
      // TODO: 旧版的手机端没有这个业务
    } else if (type == 8) { // 结束沟通-
      message = "您确定要结束沟通吗？";
    }

    return message;
  }

  /**
   * [confirmFlow 提交通用流程]
   * @param {[type]} type [提交类型]
   */
  confirmFlow(type) {
    // 下一节点处理人校验
    let checkResult = this.checkConfirmData(type);
    if (!checkResult.result) {
      let alert = this.alertCtrl.create({
        title: "提示",
        message: checkResult.message,
        buttons: [
          {
            text: "确定",
            role: 'cancel',
            handler: () => {
              //console.log('Cancel clicked');
            }
          }
        ]
      });
      alert.present();
    } else {
      let alert = this.alertCtrl.create({
        title: "提示",
        message: this.alertMessage(type),
        buttons: [
          {
            text: '取消',
            role: 'cancel',
            handler: () => {
              //console.log('Cancel clicked');
            }
          },
          {
            text: "确定",
            handler: () => {
              if (type === "2" && this.businessObjectI.bomid === "TPJ_GF_TRANSFER"
                && this.flowParmeter.nextNodesRadio != 'startCmBtn') {
                if (!this.flowParmeter.flowNotion) {
                  this.flowParmeter.flowNotion = "同意";
                }
              }
              if (type === "5" && this.businessObjectI.bomid === "TPJ_GF_TRANSFER"
                && this.flowParmeter.nextNodesRadio != 'startCmBtn') {
                if (!this.flowParmeter.flowNotion) {
                  this.flowParmeter.flowNotion = "不同意";
                }
              }
              this.update(type);
            }
          }
        ]
      });
      alert.present();
    }
  }

  /**
   * [confirmInfoFlow 提交通知公告发布、驳回]
   * @param {[type]} type [publish 发布，reject 驳回]
   */
  confirmInfoFlow(type) {
    // 下一节点处理人校验
    let checkResult = this.checkConfirmData(type);
    if (!checkResult.result) {
      let alert = this.alertCtrl.create({
        title: "提示",
        message: checkResult.message,
        buttons: [
          {
            text: "确定",
            role: 'cancel',
            handler: () => {
              //console.log('Cancel clicked');
            }
          }
        ]
      });
      alert.present();
    } else {
      let alert = this.alertCtrl.create({
        title: "提示",
        message: this.alertMessage(type),
        buttons: [
          {
            text: '取消',
            role: 'cancel',
            handler: () => {
              //console.log('Cancel clicked');
            }
          },
          {
            text: "确定",
            handler: () => {
              let needNotice = "YES"; // 是否需要送阅
              let isMsgNode = _.find(this.businessObjectDesList, {"fname": "是否发送通知消息"});

              if (isMsgNode) {
                needNotice = isMsgNode["fvalue"];
              } else {
                needNotice = "NO";
              }
              //console.log("########" + needNotion);
              this.updateInfo(type, needNotice);
            }
          }
        ]
      });
      alert.present();
    }
  }


  /**
   * [BT04 复选框控件]
   * @param {[type]} item [复选框选项内容]
   */
  BT04(item) {
    var fvalue = _.split(item.fvalue, ","); // 已选择选项

    let retVal = "";
    _.forEach(item.fieldvalDtos, function (dto) {
      if (dto && _.indexOf(fvalue, dto.fvau) > -1) {
        if (retVal == "") {
          retVal = dto.fdval;
        } else {
          retVal = retVal + ',' + dto.fdval;
        }
      }
    })
    return retVal;
  }

  /**
   * [BT0107 明细控件，type 01 ,dataType 07 ]
   * @param {[type]} item [明细信息]
   */
  BT0107(item) {
    //console.log(this.empnames);
    let modal = this.modalCtrl.create(BT0107Page, {
      "item": item,
      "bomid": this.businessObjectI.bomid
    });
    modal.present();

    modal.onWillDismiss((data: any) => {
    });

  }

  /**
   * [formateAttach 格式化附件]
   * @param {[type]} attaccNode [附件节点]
   * 返回格式：[
   * {
   *   name: // 附件标题
   *   datas: [{
   *      title : // 附件名称
   *      num : // 附件编号
   *      type: // 附件类型
   *      creator: // 创建人
   *    },
   *    {
   *      title :
   *      num :
   *      type:
   *      creator:
   *      }]
   *  },
   *  {
   *    ...
   *  }
   * ]
   */

  formateAttach(attaccNodes) {
    console.log("##格式化附件");
    console.log(attaccNodes);
    let retVal = [];
    _.forEach(attaccNodes, function (attaccNode) {

      let item = {
        name: "",
        datas: []
      };

      if (attaccNode && '' != attaccNode.fvalue) {
        item.name = attaccNode.fname;

        _.forEach(_.split(attaccNode.fvalue, ';'), function (attach) {
          let temp: any = {};
          // 第一个逗号位置， 如：34343，text.txt 【系统管理员】
          let location1 = attach.indexOf(",");
          // 第一个【位置， 如：34343，text.txt 【系统管理员】
          let location2 = attach.indexOf("【");
          // 第一个】位置， 如：34343，text.txt 【系统管理员】
          let location3 = attach.indexOf("】");

          temp.num = attach.substring(0, location1);
          temp.title = attach.substring(location1 + 1, location2);
          temp.creator = attach.substring(location2 + 1, location3);

          // 附件名称后缀名起始位置
          let location4 = temp.title.lastIndexOf(".");
          temp.type = attach.substring(location1 + location4 + 2, location2);

          item.datas.push(temp);

        });
        retVal.push(item);
      }
    });
    //console.log(retVal);
    return retVal;
  }


  /**
   * [handleFlow 下拉选择操作]
   */
  handleFlow() {
    let buttons = [
      {
        text: "流程送阅",
        role: "",
        handler: () => {
          this.navCtrl.push(FlowApprovalPage, {
            "loginId": "fengjk", // 可以任意，服务端验证当前登录和替换
            "bid": this.id,
            "wkiTitle": this.businessObjectI.bostitle,
            "bomid": this.businessObjectI.bomid
          });
        }
      },
      {
        text: "流程跟踪",
        role: "",
        handler: () => {
          this.navCtrl.push(FlowLogPage, {
            "flowProcessId": this.workFlowParmeter.flowProcessId
          });
        }
      }
    ];
    if (this.businessObjectI.sreserved3 != "5") {//流程未办结
      buttons.push({
        text: "流程催办",
        role: "",
        handler: () => {
          console.log(this.flowParmeter.nextNodeEditor);
          console.log(this.flowParmeter.nextNodeEditorName);
          this.storage.set("FlowPressPageParams", {
            "loginId": "fengjk", // 可以任意，服务端验证当前登录和替换
            "bid": this.id,
            "wkiTitle": this.businessObjectI.bostitle,
            "bomid": this.businessObjectI.bomid,
            "isSelAddr": this.isSelAddr,
            "empnames": this.workFlowParmeter.flowCurrEditorName.split(","),//全部当前处理人姓名
            "empnamesId": this.workFlowParmeter.flowCurrEditor.split(","),//全部当前处理人登录ID
            "defaultEmpnames": this.workFlowParmeter.flowCurrEditorName.split(","),//默认当前处理人姓名
            "defaultEmpnamesId": this.workFlowParmeter.flowCurrEditor.split(",")//默认当前处理人登录ID
          });
          this.navCtrl.push(FlowPressPage);
        }
      });
    }

    let actionSheet = this.actionSheetCtrl.create({
      title: '',
      buttons: _.concat(buttons, [
        {
          text: "取消",
          role: 'cancel',
          handler: () => {
            //console.log('Cancel clicked');
          }
        }
      ])
    });

    actionSheet.present();
  }

  /**
   * [BT0101WithFDtos 当fieldvalDtos能匹配到值就返回fdval，否则返回fvalue]
   * @param {[type]} item [description]
   */
  BT0101WithFDtos(item) {
    var data = _.find(item.fieldvalDtos, {"fvau": item.fvalue});
    return data ? data["fdval"] : item.fvalue;
  }

  /**
   * [toCrashPlan 付款计划]
   */
  toCrashPlan() {
    let modal = this.modalCtrl.create(CashPlanPage, {
      "bid": this.id,
    });
    modal.present();

    modal.onWillDismiss((data: any) => {
    });
  }

  /**
   * [goNTKO 发文正文详情页面]
   * @param {[type]} item [description]
   */
  goNTKO(item) {
    console.log("##正文ID：" + item["fvalue"]);
    this.navCtrl.push(InfoDetailPage, {
      //"bostitle": this.businessObjectI["bostitle"],
      // "orgname": this.businessObjectI["orgid"],
      // "bosdate": this.businessObjectI["bostime"],
      "from": "flow",
      "isRemote": "true", // 如果是信息中心则为true,反之 false
      "fbbosid": this.id,
      "isNotShowOrgnameAndBosdate": false
    });
  }

  /**
   * [goZcmx 固定资产明细页面]
   * @param {[type]} item [description]
   */
  goZcmx(item) {
    this.navCtrl.push(ZcmxListPage, {
      "zcbosid": item.fvalue
    });
  }

  /**
   * [openFile 打开附件]
   * @param {[type]} id   [description]
   * @param {[type]} name [description]
   */
  openFile(id, name) {
    console.info('-----openFile-----' + id);
    if (this.businessObjectI.bomid === "T_CM_CmAdFw") {
      this.common.openFile('flow', 'normal', id, 'true', false);
    } else {
      this.common.openFile('flow', 'normal', id, name, false);
    }
  };

  /**
   * [goEditAuth 查看编辑权限]
   * @param {[type]} item [description]
   */
  goEditAuth(item) {
    let viewListParams = {"fname": "", "isShow": true, "params": {}, "titleField": []};
    viewListParams.fname = item.fname;
    if (item["fieldid"] == "editStock") {
      viewListParams.params = {
        "tableName": "TPJ_FOS_QHZHStock_DETAIL",
        "condition": "and glbosid='" + this.id + "'",
      };
      viewListParams.titleField = ["交易类型", "交易所"];
    }
    if (item["fieldid"] == "editComm") {
      viewListParams.params = {
        "tableName": "TPJ_FOS_QHZHCOMM_DETAIL",
        "condition": "and glbosid='" + this.id + "'",
      };
      viewListParams.titleField = ["交易所", "交易编码"];
    }
    if (item["fieldid"] == "editGrove") {
      viewListParams.params = {
        "tableName": "TPJ_FOS_QHZHGrove_DETAIL",
        "condition": "and glbosid='" + this.id + "'",
      };
      viewListParams.titleField = ["交易所", "交易类型"];
    }

    if (item["fieldid"] == "editFlag") {
      viewListParams.params = {
        "tableName": "TPJ_FOS_CLOSEACCOUNTDETAIL",
        "condition": "and glbosid='" + this.id + "'",
      };
      viewListParams.titleField = ["帐户类型", "帐户名称"];
    }

    console.log(viewListParams);
    this.navCtrl.push(TaskInfoListPage, {
      "listParams": viewListParams
    });
  }

  markedWord(event) {
    console.log("选择常用指示语");
    let inputs = [];
    this.detailService.getMarkedWord().subscribe(datas => {
      this.markedWords = datas;
      _.forEach(this.markedWords, word => {
        let temp = {
          name: "markWord",
          label: word,
          value: word,
          checked: false,
          type: "radio",
          id: "markWord"
        };
        inputs.push(temp);
      });
      let alert = this.alertCtrl.create({
        title: '常用批示语',
        inputs: inputs,
        buttons: [
          {
            text: "取消",
            handler: data => {
              console.log("cancel clicked");
            }
          },
          {
            text: "确定",
            handler: data => {
              console.log(data);
              this.flowParmeter.flowNotion = data;
            }
          }
        ]
      });
      alert.present();
    });

  }

  //进入详情页
  goDetailPage(bosid) {
    this.navCtrl.push(TaskDetailPage, {
      id: bosid,
      wkiType: "6"
    });
  };

  chooseUesr() {
    let modal = this.modalCtrl.create(ContactChoosePage, {
      selected: this.selectedUsers,
      isSelectUser: false
    });

    modal.present();
    modal.onWillDismiss((userList: any[]) => {
      console.info(userList);
      if (userList) {
        this.selectedUsers = userList;
        let readContName = [];
        let full_orgnames = [];
        _.forEach(userList, user => {
          switch (user.type) {
            case "user":
              readContName.push("CN=" + user.empid + "/TI=" + user.titleid + "/OU=" + user.orgid);
              full_orgnames.push(user.full_orgname + "/" + user.name);
              this.selectedLoginid.push(user.loginid);
              break;
            case "title":
              readContName.push("TI=" + user.titleid + "/OU=" + user.orgid);
              full_orgnames.push(user.full_orgname);
              this.selectedLoginid.push(user.titleid);
              break;
            case "dept":
              readContName.push("OU=" + user.orgid);
              full_orgnames.push(user.full_orgname);
              this.selectedLoginid.push(user.orgid);
              break;
          }

        });

        this.businessObjectI.readCont = _.toString(readContName);
        this.businessObjectI.readContName = _.toString(full_orgnames);

        let index = _.findIndex(this.businessObjectDesList, {fieldid: "readContName"});
        if (index > -1) {
          this.businessObjectDesList[index].fvalue =
            this.sanitizer.bypassSecurityTrustHtml(full_orgnames.join("<br/>"));
        }
        console.log(readContName);
      }
    });
  }


  fieldSelecChange(item) {
    switch (item.fieldid) {
      case "isMsg":
        this.businessObjectI.isMsg = item.fvalue;
        break;
    }
  }


}
